Repository navigation
Serve Qwen4-MoE on Qwen4MoePipeline with Python-side image and video preprocessing - #211
Open
SearchSavior wants to merge 1 commit into
Open
SearchSavior wants to merge 1 commit into
SearchSavior wants to merge 1 commit into
Conversation
…preprocessing qwen4_moe VLMs (config.json model_type) now load as OVGenAI_Qwen4MoeVLM, a subclass of OVGenAI_VLM that runs openvino_genai.Qwen4MoePipeline. Every image and video is decoded and preprocessed in Python with the model's own Hugging Face processors (openvino_genai.qwen4_moe.Qwen4MoeProcessor); the pipeline gets pixel_values and does the rest in C++. Scheduler config, MTP draft model, CACHE_DIR, runtime_config, streamers, tool parsers and metrics are the existing VLM engine's, so the language model is built exactly as VLMPipeline builds it. - Video input: OpenAI-style video_url (base64 data URL, decoded with PyAV or OpenCV, container fps) and video (list of frame data URLs + fps). - Dispatch in create_model_instance; falls back to VLMPipeline when openvino-genai has no Qwen4MoePipeline or OPENARC_QWEN4_MOE_PIPELINE=0. - OVGenAI_VLM gets two small hooks (_create_pipeline, _vision_kwargs) and resolves inputs off the event loop. - VisionInputError: an image or video that cannot be decoded or preprocessed fails that request with 400 and keeps the model loaded, like AudioDecodeError. - Qwen4MoeForConditionalGeneration vision token for the VLMPipeline path. - Unit tests and docs/api_usage.md section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011SRNH98gDNX6mWPMJoe2DD
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Serves Qwen4-MoE (
model_type: qwen4_moe) through OpenArc's existing VLM path on the newopenvino_genai.Qwen4MoePipeline(SearchSavior/openvino.genai#7). Images and videos are decoded and preprocessed in Python with the model's own Hugging Face processors. The C++ pipeline getspixel_valuesand does the rest.This is an alternative to #208 that does not depend on it. #208 runs Qwen4 on the stock
VLMPipelineand adds the qwen35 tool-parser wiring. This PR stacks on #209 (the nightly OpenVINO index), as #208 does. The two touch one shared line inresolve_vlm_type.py, theQwen4MoeForConditionalGenerationvision token.How it plugs in
create_model_instancesendsovgenai/vlmloads whoseconfig.jsonsaysqwen4_moetoOVGenAI_Qwen4MoeVLM, a subclass ofOVGenAI_VLM. Nothing changes for other models. It falls back toVLMPipelinewhen the installedopenvino-genaihas noQwen4MoePipeline, or whenOPENARC_QWEN4_MOE_PIPELINE=0.VLMPipelinebuilds it:draft_model_path,CACHE_DIR,runtime_configcreate_generation_configOVGenAI_VLMgets two small hooks,_create_pipelineand_vision_kwargs. It also now resolves inputs withasyncio.to_thread, so image and video decoding doesn't block the event loop.textandimage_url. All media must be base64 data URLs:{"type": "video_url", "video_url": {"url": "data:video/mp4;base64,...", "fps": 30}}: decoded with PyAV, or OpenCV as a fallback. The container fps is used when nofpsis given.{"type": "video", "video": ["data:image/...", ...], "fps": 2}: frames that are already decoded.VisionInputError(ValueError): an image or video that cannot be decoded or preprocessed fails that request with HTTP 400 and keeps the model loaded, likeAudioDecodeError. Without it, the worker would unload the model on any inference exception.docs/api_usage.md.Testing
tests/unit/test_ov_genai_qwen4_moe_vlm_unit.py(22 tests) and the VLM rejection tests intest_worker_registry_unit.py. The fulltests/unitsuite gives 364 passed, 7 failed. The 7 failures are the kokoro tests, which fail identically on the base branch here becausekokorocan't be installed on this machine's Python 3.13./openarc/loadworks, and/v1/chat/completionsworks with:video_urlQwen4MoePipelinecalled directly with the same templated prompt. It is also identical toVLMPipeline(VISION_PREPROCESS=CPP) for every case.draft_model_path(MTP) works.https://image URL returns 400, and the model still answers the next request.Notes
openvino-genaithat contains Add Qwen4MoePipeline: Qwen4-MoE end to end with Python-preprocessed images and videos openvino.genai#7. Until a nightly carries it, OpenArc silently usesVLMPipelinefor qwen4_moe: images only, with a log warning.https://claude.ai/code/session_011SRNH98gDNX6mWPMJoe2DD
Generated by Claude Code